function myChart(data, element, chartType) {
var ctx = document.getElementById(element).getContext('2d');
var myChart = new Chart(ctx, {
    type: 'bar',
    data: data,
    options: {



	////



        scales: {
            y: {
                beginAtZero: true
            }
        }
    }
});






}
var data={
	"labels":["92#","0#"],
	"datasets":[
		{
			"label":"XXX销售情况",
			"fillColor":"#62a8ea",
			"data":[110,40],
		}
	]
}
function getL(){
$.ajax({
	"url":"/pay_admin/",
	"error":errorAjax,
	"dataType":"jsonp",
	"success":function(data){
		if(responseCheck(data)){
			//document.getElementById("closeButton").click()
			//加油员未结账图
			/*
			var T={
				"labels":[],
				"datasets":[
						{
						"label":"累计收款",
						"backgroundColor":[],
						"data":[],
						},
						{
						"label":"累计非会员收款",
						"backgroundColor":[],
						"data":[],
						},
						{
						"label":"累计已上缴收款",
						"backgroundColor":[],
						"data":[],
						},
						{
						"label":"累计未上缴收款",
						"backgroundColor":[],
						"data":[],
						}
					]
			}
			for (var key in data.content){
				//会员和非会员的总的收款
				T.labels.push(key)
				if (data.content[key].all===undefined){
					T.datasets[0].data.push(0)
				}
				else{
					T.datasets[0].data.push(data.content[key].all)
				}
				T.datasets[0].backgroundColor.push("#62a8ea")
				//非会员的总的收款
				if(data.content[key].offline_all===undefined){
					T.datasets[1].data.push(0)
					var offline_all=0
				}
				else{
					T.datasets[1].data.push(data.content[key].offline_all)
					var offline_all=data.content[key].offline_all
				}
				T.datasets[1].backgroundColor.push("red")


				if(data.content[key].uploaded===undefined){
					T.datasets[2].data.push(0)
					var uploaded=0
				}
				else{
					T.datasets[2].data.push(data.content[key].uploaded)
					var uploaded=data.content[key].uploaded
				}
				T.datasets[2].backgroundColor.push("green")


				T.datasets[3].data.push(offline_all - uploaded)
				T.datasets[3].backgroundColor.push("black")



			}
			console.log(T,111)
			myChart(T,"tu","Bar") */
			//声场表格
			$("tbody>tr").remove()
			if(JSON.stringify(data.content)==='{}'){
				return false;
			}
			$("#title-m").text(data.start_date+" 至 "+data.end_date)
			var tab=document.getElementById("tab")
			for (var key in data.content){
				var tr=document.createElement("tr")

				var td=document.createElement("td")
				td.textContent=key
				tr.appendChild(td)
				
				var td=document.createElement("td")
				if (data.content[key]["92"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["92"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["92"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["92"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["92"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)

				
				var td=document.createElement("td")
				if (data.content[key]["95"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["95"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["95"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["95"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["95"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)

				
				var td=document.createElement("td")
				if (data.content[key]["98"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["98"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["98"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["98"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["98"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)

				
				var td=document.createElement("td")
				if (data.content[key]["0"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["0"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["0"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["0"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["0"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)


				
				var td=document.createElement("td")
				if (data.content[key]["lng"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["lng"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["lng"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["lng"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["lng"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)


				
				var td=document.createElement("td")
				if (data.content[key]["电"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["电"].all_consumption.toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["电"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的非会员收费金额
					if(data.content[key]["电"].offline===undefined){
						td.textContent=0
					}
					else{
						td.textContent=data.content[key]["电"].offline.toFixed(2)
					}
				}
				tr.appendChild(td)


				var td=document.createElement("td")
				if (data.content[key]["consumption"]["all_charge"]===undefined){
					td.textContent=0
				}
				else{
					//每种燃油的总销售额
					td.textContent=data.content[key]["consumption"]["all_charge"].toFixed(2)
				}
				tr.appendChild(td)

				var td=document.createElement("td")
				if (data.content[key]["consumption"]["charge_cash"]===undefined){
					td.textContent=0
				}
				else{
					td.textContent=data.content[key]["consumption"]["charge_cash"].toFixed(2)
				}
				tr.appendChild(td)
				
				//判断当前是否有需要上缴的充值金额
				if (data.content[key]["consumption"]["charge_list"]===undefined){
					var charge_list=[]
					var charge=0
				}
				else{
					var charge_list=data.content[key]["consumption"]["charge_list"]
					var charge=data.content[key]["consumption"]["charge"]
				}
				





				var td=document.createElement("td")
				td.textContent=data.content[key]["handover_date"]
				tr.appendChild(td)

				var td=document.createElement("td")
				if(data.content[key].consumption["pre-uploaded_consumption"]===undefined){
					td.textContent="0"
				}
				else{
					td.textContent=data.content[key].consumption["pre-uploaded_consumption"].toFixed(2)
				}
				tr.appendChild(td)
				
				var td=document.createElement("td")
				if(data.content[key].consumption.uploaded_consumption===undefined){
					td.textContent="0"
				}
				else{
					td.textContent=data.content[key].consumption.uploaded_consumption.toFixed(2)
				}
				tr.appendChild(td)
				
				var td=document.createElement("td")
				if(data.content[key].consumption.unuploaded_consumption===undefined){
					td.textContent="0"
				}
				else{
					td.textContent=data.content[key].consumption.unuploaded_consumption.toFixed(2)
				}
				tr.appendChild(td)


				var td=document.createElement("td")
				if(data.content[key].consumption.uploading_consumption===undefined){
					td.textContent=charge.toFixed(2)
					var uploading_list=[]
					var uploading_consumption=charge
				}
				else{
					td.textContent=(data.content[key].consumption.uploading_consumption+charge).toFixed(2)
					var uploading_list=data.content[key].consumption.uploading_list
					var uploading_consumption=data.content[key].consumption.uploading_consumption + charge
				}
				tr.appendChild(td)
				
				tr.appendChild(td)


				if(data.content[key]["consumption"]===undefined){
					continue
				}
				
				var td=document.createElement("td")
				var btn=document.createElement("btn")
				btn.className="btn btn-sm btn-success"
				btn.textContent="收款"
				btn.setAttribute("unupload_list",JSON.stringify(uploading_list))
				btn.setAttribute("charge_list",JSON.stringify(charge_list))
				btn.setAttribute("uploading_consumption",uploading_consumption)
				btn.onclick=function(){
					clearInterval(window.getXXD)
					var unupload_list=$(this).attr("unupload_list")
					var _unupload_list=JSON.parse(unupload_list)
					var charge_list=$(this).attr("charge_list")
					charge_list=JSON.parse(charge_list)
					var uploading_consumption =$(this).attr("uploading_consumption")
					if(_unupload_list.length===0 && charge_list.length===0){
						showErrorInfo("当前该站长没有需要上缴的款项,或者是站长尚未发起缴款！")
						window.getXXD=setInterval(function(){
							getL()
						},1000)
						return false;
					}
					if(!confirm("您确认收到了该加油站的 ￥" + parseFloat(uploading_consumption).toFixed(2)+" 了吗？")){
						showErrorInfo("您已取消收款！")
						window.getXXD=setInterval(function(){
							getL()
						},1000)
						return false;
					}
					var data={
						"consumption_list":_unupload_list,
						"charge_list":charge_list,
					}
					data=JSON.stringify(data)
					$.ajax({
						"url":"/pay_admin/",
						"error":errorAjax,
						"complete":stop_load_pic,
						"beforeSend":start_load_pic,
						"data":{"data":data,"action":"recv"},
						"type":"POST",
						"success":function(data){
							data=JSON.parse(data)
							if(responseCheck(data)){
								alert("收款成功！")
								window.location.reload()
							}
						}
					})
				}
				td.appendChild(btn)
				tr.appendChild(td)
				
				
				tab.appendChild(tr)
			}
			//合计栏目		
			var tab=document.getElementById("tab")
			var tr=document.createElement("tr")
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			td.textContent="合计"
			tr.appendChild(td)


			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(1)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)
			
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(2)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(3)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(4)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(5)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(6)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(7)").text()
				v+= parseFloat(t)
			})

			td.textContent=v.toFixed(2)
			tr.appendChild(td)


			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(8)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(9)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(10)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(11)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(12)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(13)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(14)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			td.textContent="--"
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(16)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(17)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(18)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			//
			var td=document.createElement("td")
			td.style.fontWeight="bolder"
			td.style.fontSize="120%"
			var v=0
			$("#tab>tr").each(function(){
				t= $(this).find("td:eq(19)").text()
				v+= parseFloat(t)
			})
			td.textContent=v.toFixed(2)
			tr.appendChild(td)

			tab.appendChild(tr)

		}
	}
})
}


window.getXXD=setInterval(function(){
	getL()
},1000)
